<template>
  <div class="QhDrawer">
    <div class="QhDrawer__title" @click="toggleShow">
      <i :class="iconClass"></i>{{ title }}
    </div>
    <div class="QhDrawer__body" v-show="innerShow">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "QhDrawer",
  props: {
    title: {
      type: String,
      default: "未命名",
    },
    show: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      innerShow: this.show,
    }
  },
  computed: {
    iconClass() {
      return this.innerShow ? "el-icon-caret-bottom" : "el-icon-caret-left"
    },
  },
  methods: {
    toggleShow() {
      this.innerShow = !this.innerShow
    },
  },
}
</script>
<style lang="scss">
.QhDrawer {
  .QhDrawer__title {
    font-size: 12px;
    line-height: 25px;
    background: #eee;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 0 10px;
    touch-action: none;
    user-select: none;
    i {
      margin-right: 5px;
    }
  }
  .QhDrawer__body {
    padding: 5px;
  }
}
</style>
